package zhr.chapter8;

import java.util.Iterator;
import java.util.TreeSet;

public class Example8_8 {
    public static void main(String[] args) {
        //TreeSet会自排序
        TreeSet<Integer> treeSet1 = new TreeSet<Integer>();
        treeSet1.add(97);
        treeSet1.add(123);
        treeSet1.add(22);
        treeSet1.add(4);
        treeSet1.add(69);
        treeSet1.remove(69);
        treeSet1.add(100);
        show(treeSet1);
    }
    public static void show(TreeSet<Integer> collection) {
        Iterator<Integer> it = collection.iterator();
        while (it.hasNext()) {
            System.out.println(it.next()+" ");
        }
        System.out.println();
    }
}
